import {t} from "../../i18n/index"
import {phoneNumRule} from "../common"
import type { FormRules } from 'element-plus'
// 表单数据格式
export class FormDataType {
    customerName: string = "" // 客户姓名
    phoneNumber: string = "" // 手机号
    storeTypeIndustryId: number[] = [] // 店铺类型/行业ID
    storeCount: number = 1 // 店铺数量
    leadSource: string = "1" // 线索来源
    customerAddress: string[] =  [] // 客户地址
    customerAddressDetail: string = "" // 详细地址
    remark: string = "" // 备注

    customerId: string = "" // 客户ID
    originalPhone: string = "" // 原始客户电话
    storeTypeIndustry: string = "" // 店铺类型/行业
    status: string = "" // 状态
    pageIndex: number = 0
    pageSize: number = 0
}

export class submitDataType {
    customerName: string = "" // 客户姓名
    phoneNumber: string = "" // 手机号
    storeTypeIndustryId: string = "" // 店铺类型/行业ID ----
    storeCount: number = 0 // 店铺数量
    leadSource: string = "" // 线索来源
    customerAddress: string =  "" // 客户地址 ----
    customerAddressDetail: string = "" // 详细地址
    remark: string = "" // 备注

    customerId: string = "" // 客户ID
    originalPhone: string = "" // 原始客户电话
    storeTypeIndustry: string = "" // 店铺类型/行业
    status: string = "" // 状态
    pageIndex: number = 0
    pageSize: number = 0
}

// 线索来源数据格式
export interface SelectDataType {
    title: string
    code: string
}


// 表单的校验规则
export const formDataRules:FormRules<FormDataType> = {
    customerName: [
        { required: true, message: t('clueInformation_customerMoniker_placeholder'), trigger: 'blur' },
    ],
    phoneNumber: phoneNumRule,
    storeTypeIndustryId: [
        {required:true,message:t("clueInformation_Sector_placeholder"),trigger: "blur"}
    ],
    storeCount: [
        {required:true,message: t("clueInformation_numberOfStores_placeholder"),trigger: "blur"},
        {pattern: /^(?!0)\d+$/,message: t("require_number"),trigger: "blur"},
    ],
    leadSource: [
        {required:true,message: t("clueInformation_sourceOfClues_placeholder"),trigger: "blur"},
    ],
    customerAddress: [
        {required:true,message: t("clueInformation_customerAddress_placeholder"),trigger: "blur"},
    ]
}


export type IndustryDataType = IndustryItemDataType[]


export interface IndustryItemDataType {
    industryId: number
    parenId: number
    industryName: string
    level: number
    industryOrder: number
    children: Array<Children>
}

export interface Children {
    industryId: number
    parenId: number
    industryName: string
    level: number
    industryOrder: number
    children?: Array<any>
}
